<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <button @click="dialogVisible=true">按钮</button>
        <el-dialog :visible="dialogVisible" @update:visible="dialogVisible=$event"></el-dialog>
        <el-dialog :visible.sync="dialogVisible" ></el-dialog>
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script>
        Vue.component('el-dialog',{
            props:{
                visible:{
                    type:Boolean,
                    required:true 
                }
            },
            template:`
                <div style="width:200px;height:200px;background:red;color:white;" v-show="visible">
                    <span @click="fn">X</span>
                    对话框
                </div>
            `,
            methods:{
                fn(){
                    this.$emit('update:visible',false)
                }
            }
        })
        var vm = new Vue({
            el:'#app',
            data:{
                dialogVisible:false
            },
            methods:{
                
            }
        })
    </script>
</body>
</html>
